package com.crimsec.utils.dinfo.impl.xml;

import java.net.URI;
import java.util.Collection;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "files")
public class NewsIndex {

    private String encoding;
    private URI baseUri;
    //
    private Collection<NewsItem> newsItems;

    public String getEncoding() {
        return encoding;
    }

    public void setEncoding(String encoding) {
        this.encoding = encoding;
    }

    public URI getBaseUri() {
        return baseUri;
    }

    public void setBaseUri(URI baseUri) {
        this.baseUri = baseUri;
    }

    @XmlElementWrapper(name = "items")
    @XmlElement(name = "item")
    public Collection<NewsItem> getNewsItems() {
        return newsItems;
    }

    public void setNewsItems(Collection<NewsItem> newsItems) {
        this.newsItems = newsItems;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 97 * hash + (this.encoding != null ? this.encoding.hashCode() : 0);
        hash = 97 * hash + (this.baseUri != null ? this.baseUri.hashCode() : 0);
        hash = 97 * hash + (this.newsItems != null ? this.newsItems.size() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final NewsIndex other = (NewsIndex) obj;
        if ((this.encoding == null) ? (other.encoding != null) : !this.encoding.equals(other.encoding)) {
            return false;
        }
        if (this.baseUri != other.baseUri && (this.baseUri == null || !this.baseUri.equals(other.baseUri))) {
            return false;
        }
        if (this.newsItems != other.newsItems && (this.newsItems == null || !this.newsItems.equals(other.newsItems))) {
            return false;
        }
        return true;
    }
}
